package com.peanut.baby.mvp.point;

import android.content.Context;
import android.view.View;
import android.widget.TextView;

import com.peanut.baby.R;
import com.peanut.baby.model.PointHistory;
import com.peanut.baby.util.TimeUtil;
import com.peanut.devlibrary.widget.pullrecycle.BaseRecyclerAdapter;
import com.peanut.devlibrary.widget.pullrecycle.BaseViewHolder;

import java.util.List;

/**
 * Created by anonymouslystudio on 2017/8/23.
 */

public class PointRecordRecyclerAdapter extends BaseRecyclerAdapter<PointHistory>{
    public PointRecordRecyclerAdapter(Context context, List data) {
        super(context, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, PointHistory item, int position) {
        super.convert(holder, item, position);
        View area = holder.getView(R.id.rule_area_top);
        if(position == 0){
            area.setVisibility(View.VISIBLE);
        }else{
            area.setVisibility(View.GONE);
        }
    }

    @Override
    protected void convert(BaseViewHolder holder, PointHistory item) {
        TextView name = holder.getView(R.id.rule_name);
        TextView desc = holder.getView(R.id.rule_desc);
        TextView value = holder.getView(R.id.rule_value);

        name.setText(item.pointContent);
        desc.setText(TimeUtil.getDisplayTimeMillis(item.createTime));
        value.setText(item.point+"");
        if(item.point >= 0){
            value.setTextColor(mContext.getResources().getColor(R.color.text_green));
        }else{
            value.setTextColor(mContext.getResources().getColor(R.color.colorPrimary));
        }
    }

    @Override
    protected int getLayoutId() {
        return R.layout.layout_item_point_rule;
    }


}
